#!/bin/python3

import math
import os
import random
import re
import sys

#
# Complete the 'timeConversion' function below.
#
# The function is expected to return a STRING.
# The function accepts STRING s as parameter.
#

def timeConversion(s):
    # Write your code here
    # 时间格式转换
    if 'PM' in s:
        if s[:2] != '12':
            h = str(int(s[:2])+12)
    elif 'AM' in s:
        if s[:2] == '12':
            h = '00'
    if 'h' not in locals():
        return s[:-2]
    else:
        return h+s[2:-2]

if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    s = input()

    result = timeConversion(s)

    fptr.write(result + '\n')

    fptr.close()